package com.example.ribbonconsumer.rest;

import com.example.ribbonconsumer.service.HelloService;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by yxw on 2017/10/18.
 */
@RestController
public class ConsumerController {

    @Autowired
    private HelloService helloService;

    @RequestMapping(value = "/ribbon-consumer", method = RequestMethod.GET)
    @HystrixCommand(fallbackMethod = "helloFallback")
    public String helloConsumer() {
        return helloService.helloService();
    }

    /*public String hello() throws Exception {
        long start = System.currentTimeMillis();
        long end = System.currentTimeMillis();
        return
    }*/

    public String helloFallback() {
        return "error";
    }


}
